$(document).ready(function () {
    ggcx.onLoad();
})

var ggcx = (function () {
    var init = function () {
        var window_h = $(window).height();
        var footer_h = $(".footer").height();
        $(".ggfw_box").css("height", window_h - footer_h + "px");
        var cSname=commonJS.getQueryString("n");
        $(".ggfw_navul li").each(function(){
        	if($(this).hasClass(cSname)){
        		var dataUrl = $(this).find('a').attr("data-url");
                $("#ggmk_iframe").attr("src", dataUrl);
                $(this).addClass("active");
                $(this).siblings().removeClass("active");
        	}
        })
    }
    
    

    return {
        onLoad: function () {
            init();
            ggcx.clickIcon();
        },
        //鼠标点击更换背景和图标	
        clickIcon: function () {
            $(".ggfw_navul li").click(function () {
                var dataUrl = $(this).find('a').attr("data-url");
                $("#ggmk_iframe").attr("src", dataUrl);
                $(this).addClass("active");
                $(this).siblings().removeClass("active");
            });
        },
        openTab: function (obj) {
            switch (obj.spType) {
                case 'wsz':
                    layui.use('layer', function () {
                        var layer = layui.layer;
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-wsz', //样式类名
                            closeBtn: 1, //不显示关闭按钮
                            anim: 2,
                            title: '税票明细',
                            area: ['900px', '450px'],
                            shadeClose: true, //开启遮罩关闭
                            content: $('.wxn_wsz')
                        });
                    });
                    this.onQueryWSZ(obj);
                    break;
                case 'ccs':
                    layui.use('layer', function () {
                        var layer = layui.layer;
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-wsz', //样式类名
                            closeBtn: 1, //不显示关闭按钮
                            anim: 2,
                            title: '税票明细',
                            area: ['900px', '450px'],
                            shadeClose: true, //开启遮罩关闭
                            content: $('.wxn_ccs')
                        });
                    });
                    this.onQueryCCS(obj);
                    break;
                default:
                    layui.use('layer', function () {
                        var layer = layui.layer;
                        layer.open({
                            type: 1,
                            skin: 'layui-layer-wsz', //样式类名
                            closeBtn: 1, //不显示关闭按钮
                            anim: 2,
                            title: '税票明细',
                            area: ['900px', '450px'],
                            shadeClose: true, //开启遮罩关闭
                            content: $('.wxn_qgs')
                        });
                    });
                    this.onQueryQGS(obj);

            }

        },

        onQueryWSZ: function (obj) {

            var NSRSBH = obj.NSRSBH.trim();
            var DZSPHM = obj.JDH.trim();

            $.ajax({
                url: jsptHtp + "/web/server/platform/sscx/selWszQuery.do",
                type: "GET",
                data: {
                    NSRSBH: NSRSBH,
                    DZSPHM: DZSPHM,
                    WZSMXCX: "Y",
                    CUR_USERID: "",
                    START: "1",
                    END: "10"
                },
                dataType: "jsonp",
                jsonpCallback: "ggcx.onqueryWSZCallback",
            });


        },

        onqueryWSZCallback: function (jsonObj) {
                switch (jsonObj.code) {
                    case "0":
                        if ($.fn.dataTable.isDataTable('#wxlspzwcx1')) {
                            var table = $('#wxlspzwcx1').DataTable();
                            table.destroy();
                        }
                        $('#wxlspzwcx1').DataTable({
                            "data": jsonObj.data,
                            "columns": [{
                                    "data": null,
                                    "render": function (data, type, full, meta) {
                                        return meta.row + 1 + meta.settings._iDisplayStart;
                                    }
                                }, {
                                    "data": "ZSPM"
                                },
                                {
                                    "data": "SL"
                                },
                                {
                                    "data": "JSYJ"
                                },
                                {
                                    "data": "SJSK"
                                }
                            ],
                            "ordering": false,
                            "info": false,
                            "lengthChange": false,
                            "searching": false,
                            "paging": false
                        })
                        break;
                    default:
                        layui.use('layer', function () {
                            var layer = layui.layer;
                            layer.msg(jsonObj.msg);
                        })
                }
            }

            ,

        onQueryCCS: function (obj) {

            var DZSPHM = obj.JDH.trim();

            $.ajax({
                url: jsptHtp + "/web/server/platform/sscx/selCcsmxQuery.do",
                type: "GET",
                data: {
                    DZSPHM: DZSPHM,
                    CUR_USERID: "",
                    START: "1",
                    END: "10"
                },
                dataType: "jsonp",
                jsonpCallback: "ggcx.onqueryCCSCallback",
            });


        },

        onqueryCCSCallback: function (jsonObj) {
            switch (jsonObj.code) {
                case "0":
                    if ($.fn.dataTable.isDataTable('#wxlspzwcx2')) {
                        var table = $('#wxlspzwcx2').DataTable();
                        table.destroy();
                    }
                    $('#wxlspzwcx2').DataTable({
                        "data": jsonObj.data,
                        "columns": [{
                                "data": null,
                                "render": function (data, type, full, meta) {
                                    return meta.row + 1 + meta.settings._iDisplayStart;
                                }
                            }, {
                                "data": "ZSPM"
                            },
                            {
                                "data": "SL"
                            },
                            {
                                "data": "JSYJ"
                            },
                            {
                                "data": "SJSK"
                            }
                        ],
                        "ordering": false,
                        "info": false,
                        "lengthChange": false,
                        "searching": false,
                        "paging": false
                    })
                    break;
                default:
                    layui.use('layer', function () {
                        var layer = layui.layer;
                        layer.msg(jsonObj.msg);
                    })
            }
        },
        onQueryQGS: function (obj) {
            var result = [];
            result.push(obj);
            if ($.fn.dataTable.isDataTable('#wxlspzwcx3')) {
                var table = $('#wxlspzwcx3').DataTable();
                table.destroy();
            }
            $('#wxlspzwcx3').DataTable({
                "data": result,
                "columns": [{
                        "data": null,
                        "render": function (data, type, full, meta) {
                            return meta.row + 1 + meta.settings._iDisplayStart;
                        }
                    }, {
                        "data": "ZSPM"
                    },
                    {
                        "data": "SL"
                    },
                    {
                        "data": "JSYJ"
                    },
                    {
                        "data": "SJSK"
                    }
                ],
                "ordering": false,
                "info": false,
                "lengthChange": false,
                "searching": false,
                "paging": false
            })
        }

    }
})();